<template>
  <div class="index">
    <div class="title">
      <h3>饿了么</h3>
      <input type="text" placeholder="输入商家、商品名称" @click="search" />
    </div>


            <van-swipe class="my-swipe" :autoplay="2000" indicator-color="white" :loop="true" :height="100">
  <van-swipe-item v-for="(item, index) in bannerlist"
        :key="index"><img
        :src="item.bannerUrl"
      /> </van-swipe-item>
</van-swipe>


    
    <h4>猜你喜欢</h4>
    <div class="nav">
      <div class="sort">综合排序</div>
      <div class="distances">距离最近</div>
      <div class="sales">销量最高</div>
      <div class="screen">筛选</div>
    </div>
    <div class="opts">
      <span v-for="(item, index) in optslist" :key="index">
        {{ item }}
      </span>
    </div>
    <div class="shoplist">
      <div
        @click="handleClick(item.mtWmPoiId)"
        class="item"
        v-for="(item, index) in shoplist"
        :key="index"
      >
        <div class="left">
          <img :src="item.picUrl" alt="" />
        </div>
        <div class="right">
          <div class="name">
            {{ item.name }}
          </div>
          <div class="monthSalesTip">
            {{ item.monthSalesTip }}
          </div>
          <div class="take">
            <div class="minPriceTip">
              {{ item.minPriceTip }}
            </div>
            <div class="shippingFeeTip">
              {{ item.shippingFeeTip }}
            </div>
            <div class="takeTime">
              {{ item.deliveryTimeTip }}
            </div>
            <div class="distance">
              {{ item.distance }}
            </div>
          </div>
          <!-- <div class="manjian">
            <span v-for="(item, index) in manjianlist" :key="index">
              {{ item.info }}
            </span>
          </div> -->
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { banner, shop_list, shop_info } from "../../api/index";

export default {
  data() {
    return {
      bannerlist: [],
      optslist: ["年货节热卖", "津贴联盟", "满减优惠", "品质联盟"],
      shoplist: [],
    };
  },
  methods: {
    search() {
      this.$router.push("/search");
    },
    handleClick(id) {
      shop_info({ id: id }).then((res) => {
        if (res.data.code == 200) {
          this.$router.push({ path: "/shopinfo/" + id });
        } else {
          alert("该商家已倒闭");
        }
      });
    },
  },
  mounted() {
    banner().then((res) => {
      this.bannerlist = res.data.list;
    }),
      shop_list().then((res) => {
        this.shoplist = res.data.list;
      });
    /* setInterval(()=>{
            
        },1000) */
  },
};
</script>

<style scoped>

.title {
  height: 90px;
  color: white;
  padding: 5px 10px;
  background-color: #39a9ed;
}
h3 {
  height: 40px;
  line-height: 40px;
  padding: 0 10px;
  margin-bottom: 5px;
}
input {
  width: 100%;
  height: 30px;
  border-radius: 20px;
  text-align: center;
}
  .my-swipe .van-swipe-item {
    color: #fff;
    font-size: 20px;
    /* line-height: 100px; */
    text-align: center;
    padding: 0 10px;
    margin: 10px 0;
    /* background-color: yellow; */
  }
 .my-swipe .van-swipe-item img{
  width: 100%;
  border-radius: 5px;
 }
h4 {
  padding: 10px;
}
.nav {
  display: flex;
  padding: 0 10px;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
  cursor: pointer;
}
.opts {
  padding: 0 10px;
  font-size: 12px;
  color: gray;
  display: flex;
  justify-content: space-between;
}
.opts span {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 2px;
  background-color: gainsboro;
  margin-bottom: 10px;
}
.shoplist {
  height: 320px;
  overflow-y: auto;
  padding: 0 10px;
  /* background-color: red; */
}
::-webkit-scrollbar {
  display: none;
}
.item {
  height: 100px;
  display: flex;
  margin-bottom: 10px;
}
.left {
  width: 80px;
  height: 80px;
  margin-right: 10px;
}
.left img {
  width: 100%;
  height: 100%;
}
.right {
  width: 280px;
  height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.name {
  font-weight: 700;
}
.take,
.monthSalesTip {
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  color: gray;
}
</style>